package com.ellricky.teacher.ui

import android.os.Bundle
import com.andr.common.ui.activity.BaseActivity
import com.andr.common.ui.mvp.BasePresenter
import com.andr.common.widget.bnb.BnbUtil
import com.ellricky.baselib.BaseConstant
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.ui.SchoolOverviewFragment
import com.ellricky.baselib.ui.msg.MsgTipFragment
import com.ellricky.baselib.ui.order.StudentWorksFragment
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.teacher.R
import com.ellricky.teacher.ui.mycourse.MyCourseFragment
import com.ellricky.teacher.ui.mycourse.course.ClassRecordFragment
import kotlinx.android.synthetic.main.tc_activity_main.*

class TeacherMainActivity : BaseActivity<Void, BasePresenter<Void>>() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        LocalCacheUtil.setIsReloadData(true)
    }

    override fun onPause() {
        super.onPause()
        LocalCacheUtil.setIsReloadData(false)
    }

    override fun getContentLayout(): Int {
        return R.layout.tc_activity_main
    }

    override fun initUIView() {
        initView()
    }

    private fun initView() {
        mainView.initVP(
            listOf(
                MyCourseFragment.newInstance(),
                StudentWorksFragment.newInstance(),
                MsgTipFragment.newInstance(BaseConstant.CARD_TEACHER),
                ClassRecordFragment.newInstance(),
                SchoolOverviewFragment.newInstance()
            ), supportFragmentManager
        )

        mainView.initBnb(
            mutableListOf(
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.tc_icon_course_sel,
                    R.drawable.tc_icon_course_nor,
                    R.string.tc_my_course
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.pd_icon_am_sel,
                    R.drawable.pd_icon_am_nor,
                    R.string.base_student_work
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_msg_tip_sel,
                    R.drawable.base_icon_msg_tip_nor,
                    R.string.base_msg_tip
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_integral_sel,
                    R.drawable.base_icon_integral_nor,
                    R.string.base_class_record
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_achivement_sel,
                    R.drawable.base_icon_achivement_nor,
                    R.string.base_my_achievement
                )
            )
        )
    }

    override fun onKeyBack(isKeyBack: Boolean) {
        EAppUtil.exitApp(this)
    }
}
